package com.fantasy.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class GetConn {

	private static String dbHost = "125.1.0.26";
	private static String dbName = "pcaudit";
	private static String dbUser = "csm";
	private static String dbPassWord = "csm";

	public static Connection getConn() {
		String url = "jdbc:mysql://" + dbHost + ":3306/" + dbName + "?"
				+ "user=" + dbUser + "&password=" + dbPassWord + "&useUnicode=true&characterEncoding=UTF8";
		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(url);

		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return conn;
	}
	
	public static Connection getSharesConn(){
		return getConn("localhost", "shares", "root", "12345678");
	}
	
	public static Connection getPk10Conn(){
		return getConn("localhost", "pk10", "root", "12345678");
	}
	
	public static Connection getConn(String dbHost ,String dbName , String dbUser , String dbPassWord) {
		String url = "jdbc:mysql://" + dbHost + ":3306/" + dbName + "?"
				+ "user=" + dbUser + "&password=" + dbPassWord + "&useUnicode=true&characterEncoding=UTF8";
		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(url);
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return conn;
	}
}
